#include "ImageWrap.h"

ImageWrap::ImageWrap(const string& relPath, const string& sId, int iId) {
    Setup(relPath, sId, iId);
}

/**
 * ImageWrap::Setup
 * Loads a file to the Image item, and sets up the IDs
 * @param relPath string       Path of the file
 * @param sId string           String ID of the image
 * @param iId int              Integer ID of the image
 */
void ImageWrap::Setup(const string& relPath, const string& sId, int iId) {
    if (!img.LoadFromFile(relPath)) {
        cerr << "Error loading in image " << sId << " at " << relPath << endl;
    } else {
        cout << "Loaded in image " << relPath << " successfully!" << endl;
    }
    img.CreateMaskFromColor(sf::Color(255, 0, 255));

    /* Turn Smoothing Off, or else tiles will have lines between them */
    img.SetSmooth(false);

    this->sId = sId;
    this->iId = iId;

}

void ImageWrap::Setup(const sf::Image &image, const std::string &sId, int iId) {
    this->sId = sId;
    this->iId = iId;
    this->img = image;
    img.CreateMaskFromColor(sf::Color(255, 0, 255));
}

ImageWrap::ImageWrap(const sf::Image &image, const std::string &sId, int iId) {
    Setup(image, sId, iId);
}
